package com.example.yin.controller;

import com.example.yin.common.ErrorMessage;
import com.example.yin.common.SuccessMessage;
import com.example.yin.service.CaptchaService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.yin.domain.Captcha;

@RestController
@RequestMapping("/captcha")
public class CaptchaController {

    @Autowired
    private CaptchaService captchaService;

    @ApiOperation(value = "生成验证码拼图")
    @PostMapping("get-captcha")
    public Object getCaptcha(@RequestBody Captcha captcha) {
        Object res = captchaService.getCaptcha(captcha);
        if(res != null){
            return new SuccessMessage<ObjectUtils.Null>("获取成功").getMessage();
        }else{
            return new ErrorMessage("获取失败").getMessage();
        }
    }
}